﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../scripts/boot.js" type="text/javascript"></script>
    <script src="../scripts/swfupload/swfupload.js" type="text/javascript"></script>
    <script type="text/javascript">
        $.ajax({
            url: "../data/system.aspx?method=503",
            async: false,
            success: function (text) {
                if (text == "no")
                    window.location = "../system/error.html";
                else if (text == "out") {
                    var loginWindow = parent.mini.get("loginWindow");
                    if (!loginWindow.visible)
                        loginWindow.show();
                    var tabs = parent.mini.get("mainTabs");
                    var tab = tabs.getTab("tab$503");
                    tabs.removeTab(tab);
                }
            }
        });

        var States = [{ id: 0, text: '否' }, { id: 1, text: '是' }, { id: -1, text: '全部'}];
        var Type = [{ id: 1, text: '毕业生' }, { id: 2, text: '社会人员' }, { id: -1, text: '全部'}];
    </script>
</head>
<body>
    <div class="mini-toolbar" style="border-bottom: 0;">
        <table>
            <tr>
                <td>
                    姓名：
                    <input class="mini-textbox" id="key" emptytext="关键字" />
                    档案类型：
                    <input id="type" class="mini-combobox" style="width: 100px;" data="Type" value="-1"/>
                    是否转出：
                    <input id="state" class="mini-combobox" style="width: 100px;" data="States" value="-1"/>
                    <a class="mini-button" iconcls="icon-search" plain="true" onclick="search();">查询</a>
                    <span class="separator"></span>
                    <a class="mini-button" plain="true" iconcls="icon-excel" onclick="excelRow()">导入数据</a>
                </td>
            </tr>
        </table>
    </div>
    <div class="mini-fit" >
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" allowresize="true"
            idfield="id" multiselect="true" url="../data/system.aspx?method=GetArchivesList" sizeList="[15,20,50,100]" pageSize="15">
            <div property="columns">
                <div type="indexcolumn" width="40px" ></div>
                <div field="ar_id" width="80px" headeralign="center" align="center" allowsort="true">
                    档案编号</div>
                <div field="ar_type" width="60px" headeralign="center" align="center" allowsort="true" renderer="onTypeRenderer">
                    档案类型</div>
                <div field="ar_name" width="100px" headeralign="center" align="center" allowsort="true">
                    姓名</div>
                <div field="ar_card" width="150px" headeralign="center" align="center" allowsort="true">
                    身份证</div>
                <div field="ar_sex" width="40px" headeralign="center" align="center" allowsort="true">
                    性别</div>
                <div field="ar_birth" width="120px" headeralign="center" align="center" allowsort="true">
                    出生日期</div>
                <div field="ar_school" headeralign="left" align="center" allowsort="true">
                    毕业院校</div>
                <div field="ar_state" width="70px" headeralign="center" align="center" allowsort="true" renderer="onStateRenderer">
                    是否转出</div>
                <div field="ar_inserttime" width="120px" headeralign="center" align="center" allowsort="true">
                    入库日期</div>
            </div>
        </div>
    </div>
    <div id="editWindow" class="mini-window" title="导入档案信息" style="width: 400px; height:auto;" showmodal="true"
        allowresize="false" allowdrag="true" showFooter="true">
        <div id="editform" class="form">
            <table style="width: 98%; height: 100%;">
                <tr style="height: 20px">
                    <td>
                        <input id="fileupload1" class="mini-fileupload" name="Fdata" 
                        flashUrl="../scripts/swfupload/swfupload.swf"
                        uploadUrl="../data/system.aspx?method=ArchiveUpload"
                        onuploadsuccess="onUploadSuccess" style="width:300px;"
                        onuploaderror="onUploadError" onfileselect="onFileSelect"
                        />
                    </td>
                    <td>
                        <a class="mini-button" iconcls="icon-upload" onclick="startUpload()">导入</a>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <script type="text/javascript">
        $.ajaxSetup({
            contentType: "application/x-www-form-urlencoded;charset=utf-8",
            complete: function (XMLHttpRequest, textStatus) {
                if (XMLHttpRequest.responseText == "out") {
                    var loginWindow = parent.mini.get("loginWindow");
                    if (!loginWindow.visible)
                        loginWindow.show();
                }
            }
        });

        mini.parse();

        var grid = mini.get("datagrid1");
        search();

        function search() {
            var type = mini.get("type").getValue();
            var state = mini.get("state").getValue();
            var key = mini.get("key").getValue();
            grid.load({ type: type, key: key, state: state });
            grid.sortBy("ar_no", "desc");
        }

        function onStateRenderer(e) {
            for (var i = 0; i < States.length; i++) {
                var s = States[i];
                if (s.id == e.value)
                    return s.text;
            }
            return "";
        }

        function excelRow() {
            var form = new mini.Form("#editform");
            form.reset();
            form.loading();
            form.unmask();
            var win = mini.get("editWindow");
            if (!win.visible)
                win.show();
        }

        function onFileSelect(e) {
            if (e.file.type != ".xls")
                ShowMessage("系统提示", "请选择EXCEL文件！", 2);
        }

        function onUploadSuccess(e) {
            mini.unmask(document.body);
            if (e.serverData == "out") {
                var loginWindow = parent.mini.get("loginWindow");
                if (!loginWindow.visible)
                    loginWindow.show();
                return;
            }
            else if (e.serverData == "no") {
                ShowMessage("系统提示", "对不起，您没有此操作权限！", 3);
                this.setText("");
                return;
            }
            else if (e.serverData == "1") {
                ShowMessage("系统提示", "导入成功！", 1);
                this.setText("");
                mini.get("editWindow").hide();
                grid.reload();
            }
            else if (e.serverData == "0")
                ShowMessage("系统提示", "表格中没数据！", 2);
            else
                ShowMessage("系统提示", "导入失败！", 3);
        }

        function onUploadError(e) {
            mini.unmask(document.body);
            ShowMessage("系统提示", "导入失败！", 3);
        }

        function startUpload() {
            var fileupload = mini.get("fileupload1");
            mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '导入中，请稍后...' });

            fileupload.startUpload();
        }
    </script>
</body>
</html>